home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Libraries / DA.Lib < prev    next >
Encoding:
Text File  |  1993-12-17  |  7.5 KB  |  195 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        DA.Lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    <1.0.8+>    11/19/93    NAGA        modify TCS format
  19. #     <1.0.8>     9/23/93    KTA        ScrapBook() -Changed calls to launchTwitch so they twitch but do
  20. #                                    not launch the previousApp.
  21. #     <1.0.7>     8/25/93    KTA        Added support for parity checking the TCS stack.
  22. #     <1.0.6>      8/4/93    KTA        ScrapBook() - Match of the window wasn't using gScrapTitle.
  23. #     <1.0.5>     7/30/93    KTA        ScrapBook() - updates so when scrapbook doesn't have enough
  24. #                                    memory to launch it will be handled as expected failure.
  25. #     <1.0.4>     7/14/93    KTA        Changes for international support
  26. #     <1.0.3>      7/6/93    KTA        Change a couple of Println's to LogStr's
  27. #        <1+>     5/21/93    NAGA        Adding header and porting old files to follow new standards
  28. #
  29. # ****************************************************************************
  30. #
  31.  
  32. ########################################################################
  33. #                            External libraries 
  34. #=======================================================================
  35. Libraries "Output.Lib","TCS.Lib","LaunchQuit.Lib","TargetCheck.Lib","UserInterface.Lib";
  36.  
  37. #########################################################################
  38. #                Scrapbook(requestElement,ccpFlag,pasteFlag)
  39. #========================================================================
  40. # Author:        KTA
  41. # Description:    This routine will select the scrapbook, scroll to the
  42. #                designated requestElement position, select Cut, Copy, Paste,
  43. #                or Clear from the Edit menu, close the scrapbook if under System
  44. #                6.0.x, and then select Paste if the pasteFlag parameter is 1.
  45. # Parameters:    requestElement - the element in the scrapbook to scroll to
  46. #                ccpFlag -    1 for copy
  47. #                            2 for cut
  48. #                            3 for paste
  49. #                            4 for clear
  50. #                pasteFlag - 1 to paste after closing Scrapbook
  51. #                            0 not to paste after closing Scrapbook
  52. # Returns:        0 - Couldn't complete operation
  53. #                element - Scrapbook element that operation took place on
  54. # Examples:        Scrapbook(2) will scroll the horizontal bar to the
  55. #                second entry and then copy, close and paste.
  56. # Assumptions:    That the scrollbars are present. That the string
  57. #                'Scrapbook' appear somewhere in the name
  58. #========================================================================
  59. # History:
  60. # KTA    7/7/93    Made the title of the scrapbook a global, changed references to it.
  61. #                 changed cut, copy, paste, clear to be referenced by ordinality
  62. #                final paste into app is KeyEq('v'); (all changes to support intl)
  63. # KTA    8/4/93    Match of the window wasn't using gScrapTitle
  64. # KTA    8/24/93    TCS stack parity check
  65. # KTA    9/23/93    Changed calls to launchTwitch so they twitch but do not launch the previousApp.
  66. #########################################################################
  67. TASK Scrapbook(requestElement,ccpFlag := 1,pasteFlag := 1) 
  68. begin
  69.     Global gPrevAppTitle,gIntegration,kScrapTEXT,kScrapPICT,gAppTitle, gScrapTitle;
  70.     temp := gIntegration;    
  71.     Integration := 0;            #To turn off global Integration - KTA
  72.     tempgBackgroundQuit:= global gBackgroundQuit;
  73.     gBackgroundQuit:= 0;
  74.     tempgForceQuit:= global gForceQuit;
  75.     gForceQuit:= 0;
  76.     tempgFillMemory:= global gFillMemory;
  77.     gFillMemory:= 0;
  78.     LogStr( "==========================================================");
  79.     LogStr("Performing Scrapbook DA test.");
  80.     returnval:=0;
  81.     failStr := '';
  82.     ScrapDescriptor := '';    
  83.     if(requestElement = kScrapPICT)
  84.         TCSNUM := 1;
  85.     else if(requestElement = kScrapTEXT)
  86.         TCSNUM := 2;
  87.     else
  88.         TCSNUM := 3;
  89.     
  90.     TCSStart({ TCSNUM, global kTCSetScrapBook }, 'ScrapBook');
  91.     if not(gAppTitle)
  92.         MatchApplication(0);
  93.     If(LaunchTwitch(gScrapTitle,,0,0))
  94.     begin
  95.         LogStr("Opened the Scrapbook");
  96.         scBook := match [window t:gScrapTitle o:1]!;
  97.         if(scBook.k[1].t = 'Play Sound') #put in fix for 7.0ß4 where sound button is control [1]
  98.             SkrollBar := scBook.k[2];
  99.         else
  100.             SkrollBar := scBook.k[1];
  101.         status := SkrollBar.s;
  102.         if (status <> { 0, -1 })
  103.         begin                                        # if scrollbar is enabled...
  104.             error := 0;                                # no errors yet
  105.             elementCount := status[2] + 1;            # elementCount = number of scrapbook elements
  106.             currentElement := status[1] + 1;        # currentElement = current position in Scrapbook
  107.             newCount := elementCount + 1;
  108.     
  109.             if (requestElement>elementCount) begin    # if position is greater than total elements in Scrapbook.. 
  110.                 if (ccpFlag = 1)
  111.                     LogStr("!@#$% Scrapbook entry {requestElement} does not exist! - Copying entry {currentElement} of {elementCount}");
  112.                 else if (ccpFlag = 3)
  113.                     LogStr("!@#$% Scrapbook entry {requestElement} does not exist! - Pasting to entry {currentElement} of {newCount}");
  114.                 else begin
  115.                     LogStr("!@#$% Can∂'t Cut/Clear - Scrapbook entry {requestElement} does not exist! Closing Scrapbook!");
  116.                     error := 1;    # don't clear or cut if requested item not there
  117.                 end;
  118.             end;
  119.             else begin# we've got a valid Scrapbook entry
  120.                 scroll SkrollBar a:{requestElement,elementCount};
  121.                 match [scrollbar s:?status]!;
  122.                 currentElement := status[1] + 1;        # currentElement = current position in Scrapbook
  123.                 LogStr("Scrolled to item {currentElement} of {elementCount} of the ScrapBook");
  124.                 wait(1);
  125.             end;
  126.             
  127.             if (not error) begin
  128.                 if (ccpFlag = 1) begin    # Copy Item
  129.                     if not( SelectMenuItem(4, 3))    # error - couldn't copy
  130.                         error := 1;        # prepare to abort
  131.                 end;
  132.                 else if (ccpFlag = 2)  begin
  133.                     if (not SelectMenuItem(3, 3))    # error - couldn't cut    
  134.                         error := 1;        # prepare to abort
  135.                 end;
  136.                 else if (ccpFlag = 3)  begin
  137.                     if (not SelectMenuItem(5, 3))    # error - couldn't cut    
  138.                         error := 1;        # prepare to abort
  139.                     else
  140.                         LogStr("Pasted to entry {currentElement} of {newCount}");                        
  141.                 end;
  142.                 else if (ccpFlag = 4)  begin
  143.                     if (not SelectMenuItem(6, 3))    # error - couldn't clear    
  144.                         error := 1;        # prepare to abort
  145.                 end;
  146.             end;
  147.             wait(2);
  148.             LaunchTwitch(gPrevAppTitle,,0);        # Twitch to it but don't launch it
  149.  
  150.             if not (error)
  151.             begin
  152.                 if (pasteFlag)    begin    # if we're supposed to paste back into document, do it
  153.                     wait(3);
  154.                     if (keyEq('v'))
  155.                     begin
  156.                         LogStr("==========================================================");
  157.                         returnval:=1;
  158.                     end;
  159.                 end;
  160.                 returnval:= currentElement;    # everything went OK
  161.             end; # if not (error)
  162.         end; # if scrollbar is enabled...
  163.         else begin
  164.             failStr := '!@#$% The horizontal scroll bar was not enabled to scroll';
  165.             LogStr(failStr);
  166.             closeWindow();
  167.         end;
  168.     end; # If(LaunchTwitch('Scrapbook'))
  169.     else begin
  170.         scrapReturn := -1;        # couldn't launch is an expected failure
  171.         LaunchTwitch(gPrevAppTitle,,0);        # Twitch to it but don't launch it
  172.         failStr := "Couldn't launch the Scrapbook";
  173.     end;
  174.  
  175.     if (returnVal)    # Return pass or fail
  176.     begin
  177.         ScrapReturn := 1;
  178.         ScrapDescriptor := returnVal;
  179.     end;
  180.     else
  181.     begin
  182.         if not(scrapReturn = -1)    # Couldn't launch
  183.             ScrapReturn := 0;
  184.     end;
  185.     
  186.     TCSEnd({ TCSNUM, global kTCSetScrapBook }, ScrapReturn,failStr,,ScrapDescriptor);            # End TCS
  187.     gBackgroundQuit:= tempgBackgroundQuit;
  188.     gForceQuit:= tempgForceQuit;
  189.     gFillMemory:= tempgFillMemory;
  190.     gIntegration := temp;            #To reset the integration global - KTA
  191.     
  192.     return(returnval);
  193.  
  194. end; # Scrapbook()
  195.